﻿@model ContactForm.Models.ContactFormModel

@{
    ViewBag.Title = "Info";
    Microsoft.Web.Helpers.ReCaptcha.PublicKey = Session["ReCaptchaPublicKey"].ToString();
    string street = "";
    string address = "";
    string getdirections = "";
    Core.Tools.DebugInfo("Contact Form Info: View loaded, computing strings");
    street = Server.HtmlEncode(Model.BusinessUnit.Address.Line1) + (String.IsNullOrEmpty(Model.BusinessUnit.Address.Line2) ? "" : "<br />" + Server.HtmlEncode(Model.BusinessUnit.Address.Line2));
    address = street.Replace("<br />",", ") + ", " + Model.BusinessUnit.Address.City;
    address += String.IsNullOrEmpty(Model.BusinessUnit.Address.State) ? "" : ", " + Model.BusinessUnit.Address.State;
    address += String.IsNullOrEmpty(Model.BusinessUnit.Address.PostalCode) ? "" : " - " + Model.BusinessUnit.Address.PostalCode;
    address += String.IsNullOrEmpty(Model.BusinessUnit.Address.Country) ? "" : ", " + Model.BusinessUnit.Address.Country;
    getdirections = "http://maps.google.com/maps?f=d&source=d&daddr=" + address.Replace(" ","+");
    Core.Tools.DebugInfo("Contact Form Info: street = " + street);
    Core.Tools.DebugInfo("Contact Form Info: getdirections = " + getdirections);
}

<h2>Contact Us</h2>

@using (Html.BeginForm())
{
    @Html.ValidationSummary(false)
    <fieldset>

        @Html.HiddenFor(model => model.Id)
        @Html.HiddenFor(model => model.BusinessUnit.BusinessUnitId)
        @Html.HiddenFor(model => model.BusinessUnit.BusinessUnitName)
        @Html.HiddenFor(model => model.BusinessUnit.Phone)
        @Html.HiddenFor(model => model.BusinessUnit.Email)

        <div>
        <div style="float: left; vertical-align: top; width: 60%">
        <table border="0" cellspacing="0" cellpadding="3">
        <tr>
        <td>
        <div class="editor-label">
            @Html.LabelFor(model => model.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstName)
        </div>
        </td><td>
        <div class="editor-label">
            @Html.LabelFor(model => model.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastName)
        </div>
        </td>
        <td width="98%"></td>
        </tr>
        <tr>
        <td colspan="3">
        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Email, new { size = "40" })
        </div>
        </td></tr>
        <tr><td colspan="3">
        <div class="editor-label">
            @Html.LabelFor(model => model.Subject)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Subject, new { size = "40" })
        </div>
        </td></tr>
        <tr><td colspan="3">
        <div class="editor-label">
            @Html.LabelFor(model => model.Message)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Message, new { cols = "40", rows = "5" })
			<script type="text/javascript">
			//<![CDATA[
			    CKEDITOR.replace('Message',
					{
					    toolbar: 'Basic',
					    skin: 'v2',
                        forcePasteAsPlainText: true
					});
			//]]>
			</script>
        </div>
        </td></tr>
        <tr><td colspan="3">
        <div id="recaptcha" class="editor-field">
            @Microsoft.Web.Helpers.ReCaptcha.GetHtml(theme: "white")
        </div>
        </td></tr>
        <tr><td colspan="3">
        <div class="editor-field">
            @Html.CheckBoxFor(model => model.OptIn) &nbsp; @Html.LabelFor(model => model.OptIn)
        </div>
        </td></tr>
        <tr><td colspan="3">
        &nbsp;
        </td></tr>
        <tr><td colspan="3">
        <input type="submit" value="Send" />
        </td></tr>
        </table>
        </div>
        <div style="float: right; vertical-align: top; width: 40%;">
@{
       if ((bool)ViewBag.DisplayAddress)
       {
        <p style="padding: 0px 20px">
        <strong>@Html.DisplayFor(m => m.BusinessUnit.BusinessUnitName)</strong><br />
        @Html.Raw(street)<br />
        @Html.DisplayFor(m => m.BusinessUnit.Address.City), @Html.DisplayFor(m => m.BusinessUnit.Address.State) - @Html.DisplayFor(m => m.BusinessUnit.Address.PostalCode)<br />
        </p>
        <p style="padding: 0px 20px">
        P: @Html.DisplayFor(m => m.BusinessUnit.Phone)<br />
        F: @Html.DisplayFor(m => m.BusinessUnit.Fax)<br />
        E: @Html.DisplayFor(m => m.BusinessUnit.Email)
        </p>
        <p style="padding: 20px">
        @Html.GoogleMap(new
        {
            zoom = 15,
            size = "300x300",
            center = address,
            sensor = "false",
            markers = "color:red|" + address
        })
        <br />
        <a href="@Html.Raw(getdirections)" target="_blank">Get Directions</a>
        </p>
       }
}
        </div>
        <div style="clear: both"></div>
        </div>
    </fieldset>
}
